Skip to content

ref(samples): [Queue Instrumentation 19] Drop Kafka auto-config exclude from Spring Boot samples#5314

Draft
adinauer wants to merge 1 commit intoref/queue-instrumentation-kafka-sample-packagefrom
ref/queue-instrumentation-kafka-sample-autoconfig
Draft

ref(samples): [Queue Instrumentation 19] Drop Kafka auto-config exclude from Spring Boot samples#5314
adinauer wants to merge 1 commit intoref/queue-instrumentation-kafka-sample-packagefrom
ref/queue-instrumentation-kafka-sample-autoconfig

Conversation

@adinauer
Copy link
Copy Markdown
Member

@adinauer adinauer commented Apr 21, 2026

PR Stack (Queue Instrumentation)


📜 Description

Remove spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration from the default application.properties and the corresponding empty override from application-kafka.properties in all three Spring Boot Jakarta samples (sentry-samples-spring-boot-jakarta, sentry-samples-spring-boot-jakarta-opentelemetry, sentry-samples-spring-boot-jakarta-opentelemetry-noagent).

No behavior change in default or kafka-profile runs.

💡 Motivation and Context

spring.autoconfigure.exclude is a single list property — profile-specific files replace it rather than merge. The existing setup worked for one queue profile but does not compose with additional transport profiles we plan to add next (e.g. rabbitmq):

# application.properties
spring.autoconfigure.exclude=KafkaAutoConfiguration,RabbitAutoConfiguration

# application-kafka.properties
spring.autoconfigure.exclude=       # clears everything → also re-enables Rabbit

# application-rabbitmq.properties
spring.autoconfigure.exclude=       # clears everything → also re-enables Kafka

Activating the kafka profile would unsilence RabbitAutoConfiguration and vice versa; --spring.profiles.active=kafka,rabbitmq becomes order-dependent rather than additive.

We can drop the exclude entirely because:

  • KafkaConsumer and KafkaController already carry @Profile("kafka"), so no @KafkaListener container starts and no broker connection is attempted when the profile is inactive.
  • KafkaAutoConfiguration still creates an unused KafkaTemplate bean in non-Kafka runs, which is harmless.
  • Sentry's Kafka auto-config (SentryKafkaQueueConfiguration in SentryAutoConfiguration) is independently gated on @ConditionalOnProperty(name = "sentry.enable-queue-tracing", havingValue = "true"). That property is only set in application-kafka.properties, so Sentry instrumentation behavior is unchanged.

This makes the samples compose cleanly with future queue-transport profiles.

💚 How did you test it?

  • ./gradlew :sentry-samples:sentry-samples-spring-boot-jakarta:compileJava :sentry-samples:sentry-samples-spring-boot-jakarta-opentelemetry:compileJava :sentry-samples:sentry-samples-spring-boot-jakarta-opentelemetry-noagent:compileJava — clean build.
  • ./gradlew spotlessApply apiDump — clean.
  • The existing KafkaQueueSystemTest already covers the kafka profile end-to-end.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Add a rabbitmq profile to the Spring Boot Jakarta samples so Kafka and Rabbit can coexist without auto-config exclusion conflicts.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

…de from Spring Boot samples

Remove `spring.autoconfigure.exclude=KafkaAutoConfiguration` from the
default `application.properties` and the matching empty override from
`application-kafka.properties` in the three Spring Boot Jakarta samples.

`spring.autoconfigure.exclude` is a single list property, so overriding
it in a profile replaces the whole list rather than merging. Adding a
sibling `rabbitmq` profile with the same pattern would not compose —
activating one profile would unsilence the other's auto-config.

The `@Profile("kafka")` annotations already on `KafkaConsumer` and
`KafkaController` gate the actual listener container and endpoint, so
no broker connection is attempted when the profile is inactive.
`KafkaAutoConfiguration` still runs and creates an unused
`KafkaTemplate` bean in that case, which is harmless.

Sentry's own Kafka auto-config remains gated on
`sentry.enable-queue-tracing=true`, which is only set in
`application-kafka.properties`, so Sentry instrumentation behavior is
unchanged.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

This was referenced Apr 21, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 21, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.37.1 (1) release

⚙️ sentry-android Build Distribution Settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant